package my.soft.aiteacher.teacher.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import my.soft.aiteacher.teacher.pojo.ChapterDo;
import my.soft.aiteacher.teacher.pojo.ChapterVo;
import my.soft.aiteacher.teacher.service.IChaptersService;
import my.soft.aiteacher.utils.R;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@Tag(name = "教师-章节管理", description = "教师-章节管理")
public class ChaptersController {
    @Resource
    private IChaptersService chaptersService;
    @PreAuthorize("hasAnyAuthority('upload:chapter')")
    @Operation(summary = "提交章节", description = "提交章节")
    @RequestMapping(value = "/submitChapters",method = RequestMethod.POST)
    public R submitChapters(@RequestBody List<ChapterVo> chapters){
        List<ChapterVo> chapterVoList = chaptersService.submitChapters(chapters);
        return R.success(chapterVoList);
    }
    @PreAuthorize("hasAnyAuthority('query:chapter')")
    @Operation(summary = "获取当前视频章节列表", description = "获取当前视频章节列表")
    @RequestMapping(value = "/chapterList",method = RequestMethod.GET)
    public R chapterList(Long fileId){
        List<ChapterDo> chapterDoList = chaptersService.chapterList(fileId);
        return R.success(chapterDoList);
    }


}
